package org.example.im.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.example.im.bean.protocol.response.Send2GroupResponsePacket;
import org.example.im.bean.session.Session;
import org.springframework.stereotype.Component;

/**
 * @author dingrui
 * @since 2022/2/12
 * @description 群消息
 */
@Component
public class Send2GroupHandler extends SimpleChannelInboundHandler<Send2GroupResponsePacket> {

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Send2GroupResponsePacket send2GroupResponsePacket) throws Exception {
        String fromGroupId = send2GroupResponsePacket.getFromGroupId();
        Session fromUser = send2GroupResponsePacket.getFromUser();
        String msg = send2GroupResponsePacket.getMsg();
        System.out.println("收到群[" + fromGroupId + "]中好友[" + fromUser + "]的消息 消息内容为: [" + msg + "]");
    }
}
